#pragma once
#include"Mutex.hpp"
#include <iostream>
#include <pthread.h>

namespace CondModle
{
    using namespace LockModule;

    class Clone
    {
    public:
        Clone()
        {
            int n = pthread_cond_init(&_cond, nullptr);
            (void)n;
        }

        void signal()
        {
            int n = pthread_cond_signal(&_cond);
            (void)n;
        }

        void wait(Mutex& mutex)
        {
            int n = pthread_cond_wait(&_cond, mutex.mutexptr());
            (void)n;
        }

        void broadcast()
        {
            int n = pthread_cond_broadcast(&_cond);
            (void)n;
        }

        ~Clone()
        {
            int n = pthread_cond_destroy(&_cond);
            (void)n;
        }

    private:
        pthread_cond_t _cond;
    };
}
